home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / MoreFiles 1.3.1 / DirectoryCopy.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-16  |  6.5 KB  |  167 lines  |  [TEXT/MMCC]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    DirectoryCopy: A robust, general purpose directory copy routine.
  5. **
  6. **    by Jim Luther, Apple Developer Technical Support
  7. **
  8. **    File:        DirectoryCopy.h
  9. **
  10. **    Copyright © 1992-1995 Apple Computer, Inc.
  11. **    All rights reserved.
  12. **
  13. **    You may incorporate this sample code into your applications without
  14. **    restriction, though the sample code has been provided "AS IS" and the
  15. **    responsibility for its operation is 100% yours.  However, what you are
  16. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  17. **    after having made changes. If you're going to re-distribute the source,
  18. **    we require that you make it clear in the source that the code was
  19. **    descended from Apple Sample Code, but that you've made changes.
  20. */
  21.  
  22. #ifndef __DIRECTORYCOPY__
  23. #define __DIRECTORYCOPY__
  24.  
  25. #include <Types.h>
  26. #include <Files.h>
  27.  
  28. /*****************************************************************************/
  29.  
  30. enum
  31. {
  32.     getNextItemOp            = 1,    /* couldn't access items in this directory - no access privileges */
  33.     copyDirCommentOp        = 2,    /* couldn't copy directory's Finder comment */
  34.     copyDirAccessPrivsOp    = 3,    /* couldn't copy directory's AFP access privileges */
  35.     copyDirFMAttributesOp    = 4,    /* couldn't copy directory's File Manager attributes */
  36.     dirCreateOp                = 5,    /* couldn't create destination directory */
  37.     fileCopyOp                = 6        /* couldn't copy file */
  38. };
  39.  
  40. /*****************************************************************************/
  41.  
  42. typedef    pascal    Boolean    (*CopyErrProcPtr) (OSErr error,
  43.                                            short failedOperation,
  44.                                            short srcVRefNum,
  45.                                            long srcDirID,
  46.                                            StringPtr srcName,
  47.                                            short dstVRefNum,
  48.                                            long dstDirID,
  49.                                            StringPtr dstName);
  50. /*    ¶ Prototype for the CopyErrProc function DirectoryCopy calls.
  51.     This is the prototype for the CopyErrProc function DirectoryCopy
  52.     calls if an error condition is detected sometime during the copy.  If
  53.     CopyErrProc returns true, then DirectoryCopy attempts to continue with
  54.     the directory copy operation.  If CopyErrProc returns false, then
  55.     DirectoryCopy stops the directory copy operation.
  56.  
  57.     error            input:    The error result code that caused CopyErrProc to
  58.                             be called.
  59.     failedOperation    input:    The operation that returned an error to
  60.                             DirectoryCopy.
  61.     srcVRefNum        input:    Source volume specification.
  62.     srcDirID        input:    Source directory ID.
  63.     srcName            input:    Source file or directory name, or nil if
  64.                             srcDirID specifies the directory.
  65.     dstVRefNum        input:    Destination volume specification.
  66.     dstDirID        input:    Destination directory ID.
  67.     dstName            input:    Destination file or directory name, or nil if
  68.                             dstDirID specifies the directory.
  69.  
  70.     __________
  71.     
  72.     Also see:    DirectoryCopy, FSpDirectoryCopy
  73. */
  74.  
  75. /*****************************************************************************/
  76.  
  77. pascal    OSErr    DirectoryCopy(short srcVRefNum,
  78.                               long srcDirID,
  79.                               StringPtr srcName,
  80.                               short dstVRefNum,
  81.                               long dstDirID,
  82.                               StringPtr dstName,
  83.                               void *copyBufferPtr,
  84.                               long copyBufferSize,
  85.                               Boolean preflight,
  86.                               CopyErrProcPtr copyErrHandler);
  87. /*    ¶ Make a copy of a directory structure in a new location.
  88.     The DirectoryCopy function makes a copy of a directory structure in a
  89.     new location. If copyBufferPtr <> NIL, it points to a buffer of
  90.     copyBufferSize that is used to copy files data.  The larger the
  91.     supplied buffer, the faster the copy.  If copyBufferPtr = NIL, then this
  92.     routine allocates a buffer in the application heap. If you pass a
  93.     copy buffer to this routine, make its size a multiple of 512
  94.     ($200) bytes for optimum performance.
  95.     
  96.     srcVRefNum        input:    Source volume specification.
  97.     srcDirID        input:    Source directory ID.
  98.     srcName            input:    Source directory name, or nil if
  99.                             srcDirID specifies the directory.
  100.     dstVRefNum        input:    Destination volume specification.
  101.     dstDirID        input:    Destination directory ID.
  102.     dstName            input:    Destination directory name, or nil if
  103.                             dstDirID specifies the directory.
  104.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  105.                             is used the i/o buffer for the copy or
  106.                             nil if you want DirectoryCopy to allocate its
  107.                             own buffer in the application heap.
  108.     copyBufferSize    input:    The size of the buffer pointed to
  109.                             by copyBufferPtr.
  110.     preflight        input:    If true, DirectoryCopy makes sure there are
  111.                             enough allocation blocks on the destination
  112.                             volume to hold the directory's files before
  113.                             starting the copy.
  114.     copyErrHandler    input:    A pointer to the routine you want called if an
  115.                             error condition is detected during the copy, or
  116.                             nil if you don't want to handle error conditions.
  117.                             Error handling is recommended...
  118.  
  119.     __________
  120.     
  121.     Also see:    CopyErrProcPtr, FSpDirectoryCopy, FileCopy, FSpFileCopy
  122. */
  123.  
  124. /*****************************************************************************/
  125.  
  126. pascal    OSErr    FSpDirectoryCopy(const FSSpec *srcSpec,
  127.                                  const FSSpec *dstSpec,
  128.                                  void *copyBufferPtr,
  129.                                  long copyBufferSize,
  130.                                  Boolean preflight,
  131.                                  CopyErrProcPtr copyErrHandler);
  132. /*    ¶ Make a copy of a directory structure in a new location.
  133.     The FSpDirectoryCopy function makes a copy of a directory structure in a
  134.     new location. If copyBufferPtr <> NIL, it points to a buffer of
  135.     copyBufferSize that is used to copy files data.  The larger the
  136.     supplied buffer, the faster the copy.  If copyBufferPtr = NIL, then this
  137.     routine allocates a buffer in the application heap. If you pass a
  138.     copy buffer to this routine, make its size a multiple of 512
  139.     ($200) bytes for optimum performance.
  140.     
  141.     srcSpec            input:    An FSSpec record specifying the directory to copy.
  142.     dstSpec            input:    An FSSpec record specifying destination directory
  143.                             of the copy.
  144.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  145.                             is used the i/o buffer for the copy or
  146.                             nil if you want DirectoryCopy to allocate its
  147.                             own buffer in the application heap.
  148.     copyBufferSize    input:    The size of the buffer pointed to
  149.                             by copyBufferPtr.
  150.     preflight        input:    If true, FSpDirectoryCopy makes sure there are
  151.                             enough allocation blocks on the destination
  152.                             volume to hold the directory's files before
  153.                             starting the copy.
  154.     copyErrHandler    input:    A pointer to the routine you want called if an
  155.                             error condition is detected during the copy, or
  156.                             nil if you don't want to handle error conditions.
  157.                             Error handling is recommended...
  158.  
  159.     __________
  160.     
  161.     Also see:    CopyErrProcPtr, DirectoryCopy
  162. */
  163.  
  164. /*****************************************************************************/
  165.  
  166. #endif    /* __DIRECTORYCOPY__ */
  167.